const { regClass } = Laya;
import { ItemReasonRadioRunBase } from "./ItemReasonRadio.generated";

@regClass()
export class ItemReasonRadio extends ItemReasonRadioRunBase {
    actClickMy:Function;
    id:number;
    trueId:number;
    onAwake(): void {
        this.value = false; 
        this.on(Laya.Event.CLICK,this,this.onClick);
    }
    onDestroy(): void {
        this.off(Laya.Event.CLICK,this,this.onClick);
    }

    setInfo(id:number,str: string) {
        this.id = id;
        this.Text.text = str;
    }

    get value() {
        return this.ImgSelect.visible;
    }
    set value(v: boolean) {
        this.ImgSelect.visible = v;
    }

    set isShowErr(v: boolean) {
        this.ImgErr.visible = v;
    }
    // 定义一个名为 hideErrImg 的方法
    hideErrImg(){
        // 将 this.ImgErr 对象的 visible 属性设置为 false，即隐藏错误图片
        this.ImgErr.visible = false;
    }
    onClick() {
        this.value = !this.value;
        // this.selectIsSuccess = this.value && (this.id == this.trueId);
        this.actClickMy?.(this.id);
    }
    isSelectSuccess() {
        // this.selectIsSuccess = this.value && (this.id == this.trueId);
        this.value = true;
    }
    clearSelect() {
        this.hideErrImg();
        this.value = false;
    }
}